package com.atguigu;

import org.junit.Test;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Transaction;

import java.util.List;

/**
 * @author 伟哥
 * @date 2021-06-21 11:15
 */
public class Jedis_03Replication {
    /**
     * 03、Replication主从复制
     */
    @Test
    public void Test_03Replication() {
        Jedis jedis_M = new Jedis("192.168.2.5", 6379);
        Jedis jedis_S = new Jedis("192.168.2.5", 6380);

        jedis_S.slaveof("127.0.0.1", 6379);

        jedis_M.set("class", "1122V2");

        try {
            Thread.sleep(2000);// 睡一下
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        String result = jedis_S.get("class");//可能有延迟，需再次启动才能使用
        System.out.println(result);
}
}